package com.qyer.lxp.common.framework.adapter;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by jiangping on 16/5/12.
 */
public class DateAdapter extends XmlAdapter<String,Date> {

    private String pattern = "yyyy-MM-dd";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);

    public Date unmarshal(String dateStr) throws Exception {
        return simpleDateFormat.parse(dateStr);
    }

    public String marshal(Date date) throws Exception {
        return simpleDateFormat.format(date);
    }

}
